package com.woniu.controller;
import com.woniu.config.ChatService;
import org.springframework.ai.zhipuai.ZhiPuAiImageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
@CrossOrigin
public class ChatController {
    @Autowired
    private ChatService chatService;

    @Autowired
    private ZhiPuAiImageModel zhiPuAiImageModel;





    @PostMapping(value = "/chat")
    public Flux<String> chat(@RequestBody String userInput) {

        Flux<String> s = chatService.processQuery(userInput);
//        s.subscribe(
//                element -> System.out.println("元素: " + element),
//                error -> System.err.println("错误: " + error),
//                () -> System.out.println("流完成")
//        );
        return s;
    }









}
